/*
 * Copyright (C) 2011, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

package xowl.interpreter.backends.mlm;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 *
 * @author Laurent WOUTERS
 */
public class MLMRepository extends xowl.interpreter.impl.BaseRepository {
    public MLMRepository(xowl.utils.logging.Logger log) {
        super(log);
        xowl.interpreter.impl.Evaluator staticEvaluator = new xowl.interpreter.impl.DefaultStaticEvaluator(this);
        this.evaluatorParts.add(staticEvaluator);
        this.defaultEvaluator.addPart(staticEvaluator);
    }
    
    @Override public void dropOntology(xowl.lang.owl2.Ontology ontology) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    @Override public void apply(xowl.interpreter.impl.AggregatedEvaluator evaluator, xowl.interpreter.Change change) throws xowl.interpreter.XOWLException {
        xowl.lang.owl2.Axiom axiom = change.getAxiom();
        java.lang.Class c = axiom.getClass();
        if (c == xowl.lang.owl2.Declaration.class) apply_axiom_Declaration(evaluator, (xowl.lang.owl2.Declaration)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.DatatypeDefinition.class) apply_axiom_DatatypeDefinition(evaluator, (xowl.lang.owl2.DatatypeDefinition)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.SubClassOf.class) apply_axiom_SubClassOf(evaluator, (xowl.lang.owl2.SubClassOf)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.EquivalentClasses.class) apply_axiom_EquivalentClasses(evaluator, (xowl.lang.owl2.EquivalentClasses)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.DisjointClasses.class) apply_axiom_DisjointClasses(evaluator, (xowl.lang.owl2.DisjointClasses)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.DisjointUnion.class) apply_axiom_DisjointUnion(evaluator, (xowl.lang.owl2.DisjointUnion)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.SubObjectPropertyOf.class) apply_axiom_SubObjectPropertyOf(evaluator, (xowl.lang.owl2.SubObjectPropertyOf)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.EquivalentObjectProperties.class) apply_axiom_EquivalentObjectProperties(evaluator, (xowl.lang.owl2.EquivalentObjectProperties)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.DisjointObjectProperties.class) apply_axiom_DisjointObjectProperties(evaluator, (xowl.lang.owl2.DisjointObjectProperties)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.InverseObjectProperties.class) apply_axiom_InverseObjectProperties(evaluator, (xowl.lang.owl2.InverseObjectProperties)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.ObjectPropertyDomain.class) apply_axiom_ObjectPropertyDomain(evaluator, (xowl.lang.owl2.ObjectPropertyDomain)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.ObjectPropertyRange.class) apply_axiom_ObjectPropertyRange(evaluator, (xowl.lang.owl2.ObjectPropertyRange)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.FunctionalObjectProperty.class) apply_axiom_FunctionalObjectProperty(evaluator, (xowl.lang.owl2.FunctionalObjectProperty)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.InverseFunctionalObjectProperty.class) apply_axiom_InverseFunctionalObjectProperty(evaluator, (xowl.lang.owl2.InverseFunctionalObjectProperty)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.ReflexiveObjectProperty.class) apply_axiom_ReflexiveObjectProperty(evaluator, (xowl.lang.owl2.ReflexiveObjectProperty)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.IrreflexiveObjectProperty.class) apply_axiom_IrreflexiveObjectProperty(evaluator, (xowl.lang.owl2.IrreflexiveObjectProperty)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.SymmetricObjectProperty.class) apply_axiom_SymmetricObjectProperty(evaluator, (xowl.lang.owl2.SymmetricObjectProperty)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.AsymmetricObjectProperty.class) apply_axiom_AsymmetricObjectProperty(evaluator, (xowl.lang.owl2.AsymmetricObjectProperty)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.TransitiveObjectProperty.class) apply_axiom_TransitiveObjectProperty(evaluator, (xowl.lang.owl2.TransitiveObjectProperty)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.SubDataPropertyOf.class) apply_axiom_SubDataPropertyOf(evaluator, (xowl.lang.owl2.SubDataPropertyOf)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.EquivalentDataProperties.class) apply_axiom_EquivalentDataProperties(evaluator, (xowl.lang.owl2.EquivalentDataProperties)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.DisjointDataProperties.class) apply_axiom_DisjointDataProperties(evaluator, (xowl.lang.owl2.DisjointDataProperties)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.DataPropertyDomain.class) apply_axiom_DataPropertyDomain(evaluator, (xowl.lang.owl2.DataPropertyDomain)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.DataPropertyRange.class) apply_axiom_DataPropertyRange(evaluator, (xowl.lang.owl2.DataPropertyRange)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.FunctionalDataProperty.class) apply_axiom_FunctionalDataProperty(evaluator, (xowl.lang.owl2.FunctionalDataProperty)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.SameIndividual.class) apply_axiom_SameIndividual(evaluator, (xowl.lang.owl2.SameIndividual)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.DifferentIndividuals.class) apply_axiom_DifferentIndividuals(evaluator, (xowl.lang.owl2.DifferentIndividuals)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.ClassAssertion.class) apply_axiom_ClassAssertion(evaluator, (xowl.lang.owl2.ClassAssertion)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.ObjectPropertyAssertion.class) apply_axiom_ObjectPropertyAssertion(evaluator, (xowl.lang.owl2.ObjectPropertyAssertion)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.NegativeObjectPropertyAssertion.class) apply_axiom_NegativeObjectPropertyAssertion(evaluator, (xowl.lang.owl2.NegativeObjectPropertyAssertion)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.DataPropertyAssertion.class) apply_axiom_DataPropertyAssertion(evaluator, (xowl.lang.owl2.DataPropertyAssertion)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.NegativeDataPropertyAssertion.class) apply_axiom_NegativeDataPropertyAssertion(evaluator, (xowl.lang.owl2.NegativeDataPropertyAssertion)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.HasKey.class) apply_axiom_HasKey(evaluator, (xowl.lang.owl2.HasKey)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.SubAnnotationPropertyOf.class) apply_axiom_SubAnnotationPropertyOf(evaluator, (xowl.lang.owl2.SubAnnotationPropertyOf)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.AnnotationPropertyDomain.class) apply_axiom_AnnotationPropertyDomain(evaluator, (xowl.lang.owl2.AnnotationPropertyDomain)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.AnnotationPropertyRange.class) apply_axiom_AnnotationPropertyRange(evaluator, (xowl.lang.owl2.AnnotationPropertyRange)axiom, !change.isAdd());
        else if (c == xowl.lang.owl2.AnnotationAssertion.class) apply_axiom_AnnotationAssertion(evaluator, (xowl.lang.owl2.AnnotationAssertion)axiom, !change.isAdd());
        else if (c == xowl.lang.actions.FunctionDefinition.class) applyAxiomFunctionDefinition(evaluator, (xowl.lang.actions.FunctionDefinition)axiom, change.isAdd());
    }
    @Override public void apply(xowl.interpreter.impl.AggregatedEvaluator evaluator, xowl.interpreter.Changeset changeset) throws xowl.interpreter.XOWLException {
        for (xowl.interpreter.Change change : changeset.getChanges())
            apply(evaluator, change);
    }
    protected void apply_axiom_Declaration(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.Declaration change, boolean negative) throws xowl.interpreter.XOWLException { }
    protected void apply_axiom_DatatypeDefinition(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.DatatypeDefinition change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.Datatype datatype = evaluator.evalDatatype(evaluator, change.getDatatype());
        xowl.lang.runtime.Datatype datarange = evaluator.evalDatatype(evaluator, change.getDatatype());
        if (!negative) datatype.setDataBase(datarange);
        else if (datatype.getDataBase() == datarange) datatype.setDataBase(null);
    }
    protected void apply_axiom_SubClassOf(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.SubClassOf change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.Class sub = evaluator.evalClass(evaluator, change.getClasse());
        xowl.lang.runtime.Class sup = evaluator.evalClass(evaluator, change.getSuperClass());
        if (sup.getInterpretationOf() == null && sup.getAllClassRestrictions().size() == 1) {
            // this is an anonymous class representing a class restriction
            if (!negative) sub.addClassRestrictions(sup.getAllClassRestrictions().iterator().next());
            else sub.removeClassRestrictions(sup.getAllClassRestrictions().iterator().next());
        } else {
            if (!negative) sub.addSubClassOf(sup);
            else sub.removeSubClassOf(sup);
        }
    }
    protected void apply_axiom_EquivalentClasses(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.EquivalentClasses change, boolean negative) throws xowl.interpreter.XOWLException {
        List<xowl.lang.runtime.Class> classes = new ArrayList<xowl.lang.runtime.Class>();
        for (xowl.lang.runtime.Class exp : xowl.interpreter.impl.Sequences.toEvaluatedList(evaluator, change.getClassSeq())) {
            for (xowl.lang.runtime.Class c : classes) {
                if (!negative) c.addClassEquivalentTo(exp);
                else c.removeClassEquivalentTo(exp);
            }
            classes.add(exp);
        }
    }
    protected void apply_axiom_DisjointClasses(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.DisjointClasses change, boolean negative) throws xowl.interpreter.XOWLException {
        List<xowl.lang.runtime.Class> classes = new ArrayList<xowl.lang.runtime.Class>();
        for (xowl.lang.runtime.Class exp : xowl.interpreter.impl.Sequences.toEvaluatedList(evaluator, change.getClassSeq())) {
            for (xowl.lang.runtime.Class c : classes) {
                if (!negative) c.addClassDisjointWith(exp);
                else c.removeClassDisjointWith(exp);
            }
            classes.add(exp);
        }
    }
    protected void apply_axiom_DisjointUnion(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.DisjointUnion change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.Class main = evaluator.evalClass(evaluator, change.getClasse());
        for (xowl.lang.runtime.Class exp : xowl.interpreter.impl.Sequences.toEvaluatedList(evaluator, change.getClassSeq())) {
            if (!negative) main.addClassDisjointWith(exp);
            else main.removeClassDisjointWith(exp);
        }
    }
    protected void apply_axiom_SubObjectPropertyOf(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.SubObjectPropertyOf change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty sub = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        xowl.lang.runtime.ObjectProperty sup = evaluator.evalObjProp(evaluator, change.getSuperObjectProperty());
        if (!negative) sub.addSubPropertyOf(sup);
        else sub.removeSubPropertyOf(sup);
    }
    protected void apply_axiom_EquivalentObjectProperties(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.EquivalentObjectProperties change, boolean negative) throws xowl.interpreter.XOWLException {
        List<xowl.lang.runtime.ObjectProperty> properties = new ArrayList<xowl.lang.runtime.ObjectProperty>();
        for (xowl.lang.runtime.ObjectProperty exp : xowl.interpreter.impl.Sequences.toEvaluatedList(evaluator, change.getObjectPropertySeq())) {
            for (xowl.lang.runtime.ObjectProperty p : properties) {
                if (!negative) p.addPropertyEquivalentTo(exp);
                else p.removePropertyEquivalentTo(exp);
            }
            properties.add(exp);
        }
    }
    protected void apply_axiom_DisjointObjectProperties(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.DisjointObjectProperties change, boolean negative) throws xowl.interpreter.XOWLException {
        List<xowl.lang.runtime.ObjectProperty> properties = new ArrayList<xowl.lang.runtime.ObjectProperty>();
        for (xowl.lang.runtime.ObjectProperty exp : xowl.interpreter.impl.Sequences.toEvaluatedList(evaluator, change.getObjectPropertySeq())) {
            for (xowl.lang.runtime.ObjectProperty p : properties) {
                if (!negative) p.addPropertyDisjointWith(exp);
                else p.removePropertyDisjointWith(exp);
            }
            properties.add(exp);
        }
    }
    protected void apply_axiom_InverseObjectProperties(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.InverseObjectProperties change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        xowl.lang.runtime.ObjectProperty inverse = evaluator.evalObjProp(evaluator, change.getInverse());
        if (!negative) inverse.setInverseOf(property);
        else if (inverse.getInverseOf() == property) inverse.setInverseOf(null);
    }
    protected void apply_axiom_ObjectPropertyDomain(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.ObjectPropertyDomain change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        xowl.lang.runtime.Class c = evaluator.evalClass(evaluator, change.getClasse());
        if (!negative) property.setDomain(c);
        else if (property.getDomain() == c) property.setDomain(null);
    }
    protected void apply_axiom_ObjectPropertyRange(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.ObjectPropertyRange change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        xowl.lang.runtime.Class c = evaluator.evalClass(evaluator, change.getClasse());
        if (!negative) property.setRange(c);
        else if (property.getRangeAs(null) == c) property.setRange(null);
    }
    protected void apply_axiom_FunctionalObjectProperty(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.FunctionalObjectProperty change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        if (!negative) property.setIsFunctional(true);
        else property.setIsFunctional(false);
    }
    protected void apply_axiom_InverseFunctionalObjectProperty(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.InverseFunctionalObjectProperty change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        if (!negative) property.setIsInverseFunctional(true);
        else property.setIsInverseFunctional(false);
    }
    protected void apply_axiom_ReflexiveObjectProperty(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.ReflexiveObjectProperty change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        if (!negative) property.setIsReflexive(true);
        else property.setIsReflexive(false);
    }
    protected void apply_axiom_IrreflexiveObjectProperty(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.IrreflexiveObjectProperty change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        if (!negative) property.setIsIrreflexive(true);
        else property.setIsIrreflexive(false);
    }
    protected void apply_axiom_SymmetricObjectProperty(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.SymmetricObjectProperty change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        if (!negative) property.setIsSymmetric(true);
        else property.setIsSymmetric(false);
    }
    protected void apply_axiom_AsymmetricObjectProperty(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.AsymmetricObjectProperty change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        if (!negative) property.setIsAsymmetric(true);
        else property.setIsAsymmetric(false);
    }
    protected void apply_axiom_TransitiveObjectProperty(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.TransitiveObjectProperty change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        if (!negative) property.setIsTransitive(true);
        else property.setIsTransitive(false);
    }
    protected void apply_axiom_SubDataPropertyOf(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.SubDataPropertyOf change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.DataProperty sub = evaluator.evalDataProp(evaluator, change.getDataProperty());
        xowl.lang.runtime.DataProperty sup = evaluator.evalDataProp(evaluator, change.getSuperDataProperty());
        if (!negative) sub.addSubPropertyOf(sup);
        else sub.removeSubPropertyOf(sup);
    }
    protected void apply_axiom_EquivalentDataProperties(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.EquivalentDataProperties change, boolean negative) throws xowl.interpreter.XOWLException {
        List<xowl.lang.runtime.DataProperty> properties = new ArrayList<xowl.lang.runtime.DataProperty>();
        for (xowl.lang.runtime.DataProperty exp : xowl.interpreter.impl.Sequences.toEvaluatedList(evaluator, change.getDataPropertySeq())) {
            for (xowl.lang.runtime.DataProperty p : properties) {
                if (!negative) p.addPropertyEquivalentTo(exp);
                else p.removePropertyEquivalentTo(exp);
            }
            properties.add(exp);
        }
    }
    protected void apply_axiom_DisjointDataProperties(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.DisjointDataProperties change, boolean negative) throws xowl.interpreter.XOWLException {
        List<xowl.lang.runtime.DataProperty> properties = new ArrayList<xowl.lang.runtime.DataProperty>();
        for (xowl.lang.runtime.DataProperty exp : xowl.interpreter.impl.Sequences.toEvaluatedList(evaluator, change.getDataPropertySeq())) {
            for (xowl.lang.runtime.DataProperty p : properties) {
                if (!negative) p.addPropertyDisjointWith(exp);
                else p.removePropertyDisjointWith(exp);
            }
            properties.add(exp);
        }
    }
    protected void apply_axiom_DataPropertyDomain(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.DataPropertyDomain change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.DataProperty property = evaluator.evalDataProp(evaluator, change.getDataProperty());
        xowl.lang.runtime.Class c = evaluator.evalClass(evaluator, change.getClasse());
        if (!negative) property.setDomain(c);
        else if (property.getDomain() == c) property.setDomain(null);
    }
    protected void apply_axiom_DataPropertyRange(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.DataPropertyRange change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.DataProperty property = evaluator.evalDataProp(evaluator, change.getDataProperty());
        xowl.lang.runtime.Datatype range = evaluator.evalDatatype(evaluator, change.getDatarange());
        if (!negative) property.setRange(range);
        else if (property.getRangeAs(null) == range) property.setRange(null);
    }
    protected void apply_axiom_FunctionalDataProperty(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.FunctionalDataProperty change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.DataProperty property = evaluator.evalDataProp(evaluator, change.getDataProperty());
        if (!negative) property.setIsFunctional(true);
        else property.setIsFunctional(false);
    }
    protected void apply_axiom_SameIndividual(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.SameIndividual change, boolean negative) throws xowl.interpreter.XOWLException {
        List<xowl.lang.runtime.Individual> individuals = new ArrayList<xowl.lang.runtime.Individual>();
        for (xowl.lang.runtime.Individual exp : xowl.interpreter.impl.Sequences.toEvaluatedList(evaluator, change.getIndividualSeq())) {
            for (xowl.lang.runtime.Individual p : individuals) {
                if (!negative) p.addSameAs(exp);
                else p.removeSameAs(exp);
            }
            individuals.add(exp);
        }
    }
    protected void apply_axiom_DifferentIndividuals(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.DifferentIndividuals change, boolean negative) throws xowl.interpreter.XOWLException {
        List<xowl.lang.runtime.Individual> individuals = new ArrayList<xowl.lang.runtime.Individual>();
        for (xowl.lang.runtime.Individual exp : xowl.interpreter.impl.Sequences.toEvaluatedList(evaluator, change.getIndividualSeq())) {
            for (xowl.lang.runtime.Individual p : individuals) {
                if (!negative) p.addDifferentFrom(exp);
                else p.removeDifferentFrom(exp);
            }
            individuals.add(exp);
        }
    }
    protected void apply_axiom_ClassAssertion(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.ClassAssertion change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.Individual individual = evaluator.evalIndividual(evaluator, change.getIndividual());
        xowl.lang.runtime.Class c = evaluator.evalClass(evaluator, change.getClasse());
        if (!negative) individual.addClassifiedBy(c);
        else individual.removeClassifiedBy(c);
    }
    protected void apply_axiom_ObjectPropertyAssertion(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.ObjectPropertyAssertion change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.Individual individual = evaluator.evalIndividual(evaluator, change.getIndividual());
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        xowl.lang.runtime.Individual value = evaluator.evalIndividual(evaluator, change.getValueIndividual());

        if (!negative) {
            xowl.lang.runtime.ObjectPropertyAssertion assertion = new xowl.lang.runtime.ObjectPropertyAssertion();
            assertion.setProperty(property);
            assertion.setIsNegative(false);
            assertion.setValueIndividual(value);
            individual.addAsserts(assertion);
        } else {
            for (xowl.lang.runtime.PropertyAssertion assertion : individual.getAllAsserts()) {
                if (assertion instanceof xowl.lang.runtime.ObjectPropertyAssertion) {
                    xowl.lang.runtime.ObjectPropertyAssertion temp = (xowl.lang.runtime.ObjectPropertyAssertion)assertion;
                    if ((temp.getPropertyAs(null) == property) && (temp.getValueIndividual() == value) && !temp.getIsNegative()) {
                        individual.removeAsserts(assertion);
                        break;
                    }
                }
            }
        }
    }
    protected void apply_axiom_NegativeObjectPropertyAssertion(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.NegativeObjectPropertyAssertion change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.Individual individual = evaluator.evalIndividual(evaluator, change.getIndividual());
        xowl.lang.runtime.ObjectProperty property = evaluator.evalObjProp(evaluator, change.getObjectProperty());
        xowl.lang.runtime.Individual value = evaluator.evalIndividual(evaluator, change.getValueIndividual());

        if (!negative) {
            xowl.lang.runtime.ObjectPropertyAssertion assertion = new xowl.lang.runtime.ObjectPropertyAssertion();
            assertion.setProperty(property);
            assertion.setIsNegative(true);
            assertion.setValueIndividual(value);
            individual.addAsserts(assertion);
        } else {
            for (xowl.lang.runtime.PropertyAssertion assertion : individual.getAllAsserts()) {
                if (assertion instanceof xowl.lang.runtime.ObjectPropertyAssertion) {
                    xowl.lang.runtime.ObjectPropertyAssertion temp = (xowl.lang.runtime.ObjectPropertyAssertion)assertion;
                    if ((temp.getPropertyAs(null) == property) && (temp.getValueIndividual() == value) && !temp.getIsNegative()) {
                        individual.removeAsserts(assertion);
                        break;
                    }
                }
            }
        }
    }
    protected void apply_axiom_DataPropertyAssertion(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.DataPropertyAssertion change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.Individual individual = evaluator.evalIndividual(evaluator, change.getIndividual());
        xowl.lang.runtime.DataProperty property = evaluator.evalDataProp(evaluator, change.getDataProperty());
        xowl.lang.runtime.Literal value = evaluator.evalLiteral(evaluator, change.getValueLiteral());

        if (!negative) {
            xowl.lang.runtime.DataPropertyAssertion assertion = new xowl.lang.runtime.DataPropertyAssertion();
            assertion.setProperty(property);
            assertion.setIsNegative(false);
            assertion.setValueLiteral(value);
            individual.addAsserts(assertion);
        } else {
            for (xowl.lang.runtime.PropertyAssertion assertion : individual.getAllAsserts()) {
                if (assertion instanceof xowl.lang.runtime.DataPropertyAssertion) {
                    xowl.lang.runtime.DataPropertyAssertion temp = (xowl.lang.runtime.DataPropertyAssertion)assertion;
                    if ((temp.getPropertyAs(null) == property) && (temp.getValueLiteral() == value) && !temp.getIsNegative()) {
                        individual.removeAsserts(assertion);
                        break;
                    }
                }
            }
        }
    }
    protected void apply_axiom_NegativeDataPropertyAssertion(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.NegativeDataPropertyAssertion change, boolean negative) throws xowl.interpreter.XOWLException {
        xowl.lang.runtime.Individual individual = evaluator.evalIndividual(evaluator, change.getIndividual());
        xowl.lang.runtime.DataProperty property = evaluator.evalDataProp(evaluator, change.getDataProperty());
        xowl.lang.runtime.Literal value = evaluator.evalLiteral(evaluator, change.getValueLiteral());

        if (!negative) {
            xowl.lang.runtime.DataPropertyAssertion assertion = new xowl.lang.runtime.DataPropertyAssertion();
            assertion.setProperty(property);
            assertion.setIsNegative(true);
            assertion.setValueLiteral(value);
            individual.addAsserts(assertion);
        } else {
            for (xowl.lang.runtime.PropertyAssertion assertion : individual.getAllAsserts()) {
                if (assertion instanceof xowl.lang.runtime.DataPropertyAssertion) {
                    xowl.lang.runtime.DataPropertyAssertion temp = (xowl.lang.runtime.DataPropertyAssertion)assertion;
                    if ((temp.getPropertyAs(null) == property) && (temp.getValueLiteral() == value) && !temp.getIsNegative()) {
                        individual.removeAsserts(assertion);
                        break;
                    }
                }
            }
        }
    }
    protected void apply_axiom_HasKey(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.HasKey change, boolean negative) throws xowl.interpreter.XOWLException {
        //TODO: complete
    }
    protected void apply_axiom_SubAnnotationPropertyOf(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.SubAnnotationPropertyOf change, boolean negative) throws xowl.interpreter.XOWLException {
        //TODO: complete
    }
    protected void apply_axiom_AnnotationPropertyDomain(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.AnnotationPropertyDomain change, boolean negative) throws xowl.interpreter.XOWLException {
        //TODO: complete
    }
    protected void apply_axiom_AnnotationPropertyRange(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.AnnotationPropertyRange change, boolean negative) throws xowl.interpreter.XOWLException {
        //TODO: complete
    }
    protected void apply_axiom_AnnotationAssertion(xowl.interpreter.impl.Evaluator evaluator, xowl.lang.owl2.AnnotationAssertion change, boolean negative) throws xowl.interpreter.XOWLException {
        //TODO: complete
    }
    
    @Override public Collection<xowl.lang.owl2.Axiom> getAxioms(xowl.lang.owl2.Ontology ontology) { return null; }
    @Override public void apply(xowl.interpreter.impl.AggregatedEvaluator evaluator, xowl.interpreter.RuleSet ruleset) {}
    @Override public void unapply(xowl.interpreter.impl.AggregatedEvaluator evaluator, xowl.interpreter.RuleSet ruleset) {}
    @Override public void apply(xowl.interpreter.impl.AggregatedEvaluator evaluator, xowl.interpreter.Transformation transformation) {}
    @Override public void unapply(xowl.interpreter.impl.AggregatedEvaluator evaluator, xowl.interpreter.Transformation transformation) {}
    @Override public xowl.interpreter.Transformer createTransformer(xowl.interpreter.Transformation transformation, boolean bindMeta) { return null; }
}
